<template>
  <uni-popup
    ref="contactPopup"
    type="bottom"
    :border-radius="32"
    background-color="#ffffff"
  >
    <view class="contact-modal-content">
      <view class="phone-number">400-998-9298</view>
      <view class="callout" @click="makePhoneCall">呼叫</view>
      <view class="cancel" @click="hide">取消</view>
    </view>
  </uni-popup>
</template>

<script>
export default {
  name: 'ContactServiceModal',
  methods: {
    // 显示弹窗
    show() {
      this.$refs.contactPopup.open();
    },
    // 隐藏弹窗
    hide() {
      this.$refs.contactPopup.close();
    },
    // 拨打电话
    makePhoneCall() {
      uni.makePhoneCall({
        phoneNumber: "400-998-9298",
        success: () => {
          console.log("拨打电话成功");
          this.hide();
        },
        fail: (err) => {
          console.log("拨打电话失败", err);
          uni.showToast({
            title: "拨打电话失败",
            icon: "none",
          });
        },
      });
    },
  },
};
</script>

<style lang="scss" scoped>
// 联系客服弹框内容样式
.contact-modal-content {
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: #ffffff;
  text-align: center;

  .phone-number {
    font-size: 26rpx;
    line-height: 130rpx;
    height: 130rpx;
    width: 100%;
    color: #808080;
    border-bottom: 3rpx solid #f0f0f0;
  }

  .callout {
    font-size: 32rpx;
    background-color: #fff;
    width: 100%;
    height: 106rpx;
    color: #000;
    border-bottom: 9rpx solid #f0f0f0;
    line-height: 106rpx;
  }

  .cancel {
    width: 100%;
    height: 106rpx;
    line-height: 106rpx;
    font-size: 32rpx;
    background-color: #ffffff;
    color: #000000;
  }
}
</style> 